package easymall.dao;

import easymall.po.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

@Mapper
public interface UserDao {
	@Select("select * from user where username = #{username} and password = #{password}")
	public User login(User user);

	@Select("select * from user where username = #{username}")
	public User checkUsername(String username);

	@Insert("insert into user(id,username,password,nickname,email) values(null,#{username},#{password},#{nickname},#{email})")
	public int regist(User user);

	@Select("select * from user where id = #{id}")
	public User getUser(Integer id);

	@Update("update user set invaild = 1 where id=#{id}")
	public int modifyValid(Integer id); //修改用户账号的有效性

	@Select("select invaild from user where id = #{id}")
	public int getValid(Integer id); //获取用户账号的有效性

	@Delete("delete from user where username = #{username} and password = #{password}")
	public int remove(User user);
}
